package sk.ygor.xtemplate.example

import sk.ygor.xtemplate.ScalaXTemplate

object ScalaXTemplateExample {
  def main(args: Array[String]) {
    val xtpl = new SomeTemplate
    xtpl.title.value = "List of members"

    xtpl.memberName.value = "Elvis"
    xtpl.memberColors.value = List("black")
    xtpl.member.parse

    xtpl.memberName.value = "Madonna"
    xtpl.memberColors.value = List("red", "pink", "yellow")
    xtpl.member.parse

    xtpl.members.parse

    xtpl.rootBlock.parse
    println(xtpl.rootBlock.getText)
  }

}

class SomeTemplate extends ScalaXTemplate {
  val title = parameter[String]

  val memberName = parameter[String]
  val memberColors = parameter[List[String]]

  val member = """
            <tr>
                <td>""" ~ memberName ~ """</td>
                <td>""" ~ memberColors ~ """</td>
            </tr>
  """

  val members = """
        <table>
          """ ~ member ~ """
        </table>
  """

  val rootBlock = """
        <h2>""" ~ title ~ """</h2>
        <hr>
  """ ~ members

}


